1 /* 2 * This file is part of gtkD. 3 * 4 * gtkD is free software; you can redistribute it and/or modify 5 * it under the terms of the GNU Lesser General Public License 6 * as published by the Free Software Foundation; either version 3 7 * of the License, or (at your option) any later version, with 8 * some exceptions, please read the COPYING file. 9 * 10 * gtkD is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNU Lesser General Public License for more details. 14 * 15 * You should have received a copy of the GNU Lesser General Public License 16 * along with gtkD; if not, write to the Free Software 17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA 18 */ 19 20 // generated automatically - do not change 21 // find conversion definition on APILookup.txt 22 // implement new conversion functionalities on the wrap.utils pakage 23 24 25 module shumate.Viewport; 26 27 private import glib.ConstructionException; 28 private import gobject.ObjectG; 29 private import gtk.Widget; 30 private import shumate.LocationIF; 31 private import shumate.LocationT; 32 private import shumate.MapSource; 33 private import shumate.c.functions; 34 public import shumate.c.types; 35 36 37 /** 38 * The object holding the coordinate, zoom-level, and rotation state of the current view. 39 * 40 * As the object implements [iface@Shumate.Location], the latitude and longitude are 41 * accessible via the interface methods. 42 */ 43 public class Viewport : ObjectG, LocationIF 44 { 45 /** the main Gtk struct */ 46 protected ShumateViewport* shumateViewport; 47 48 /** Get the main Gtk struct */ 49 public ShumateViewport* getViewportStruct(bool transferOwnership = false) 50 { 51 if (transferOwnership) 52 ownedRef = false; 53 return shumateViewport; 54 } 55 56 /** the main Gtk struct as a void* */ 57 protected override void* getStruct() 58 { 59 return cast(void*)shumateViewport; 60 } 61 62 /** 63 * Sets our main struct and passes it to the parent class. 64 */ 65 public this (ShumateViewport* shumateViewport, bool ownedRef = false) 66 { 67 this.shumateViewport = shumateViewport; 68 super(cast(GObject*)shumateViewport, ownedRef); 69 } 70 71 // add the Location capabilities 72 mixin LocationT!(ShumateViewport); 73 74 75 /** */ 76 public static GType getType() 77 { 78 return shumate_viewport_get_type(); 79 } 80 81 /** 82 * Creates a new #ShumateViewport 83 * 84 * Returns: A new #ShumateViewport 85 * 86 * Throws: ConstructionException GTK+ fails to create the object. 87 */ 88 public this() 89 { 90 auto __p = shumate_viewport_new(); 91 92 if(__p is null) 93 { 94 throw new ConstructionException("null returned by new"); 95 } 96 97 this(cast(ShumateViewport*) __p, true); 98 } 99 100 /** 101 * Get the maximal zoom level 102 * 103 * Returns: the maximal zoom level 104 */ 105 public uint getMaxZoomLevel() 106 { 107 return shumate_viewport_get_max_zoom_level(shumateViewport); 108 } 109 110 /** 111 * Get the minimal zoom level 112 * 113 * Returns: the minimal zoom level 114 */ 115 public uint getMinZoomLevel() 116 { 117 return shumate_viewport_get_min_zoom_level(shumateViewport); 118 } 119 120 /** 121 * Get the reference map source 122 * 123 * Returns: the reference #ShumateMapSource or %NULL 124 * when none has been set. 125 */ 126 public MapSource getReferenceMapSource() 127 { 128 auto __p = shumate_viewport_get_reference_map_source(shumateViewport); 129 130 if(__p is null) 131 { 132 return null; 133 } 134 135 return ObjectG.getDObject!(MapSource)(cast(ShumateMapSource*) __p); 136 } 137 138 /** 139 * Gets the current rotation 140 * 141 * Returns: the current rotation 142 */ 143 public double getRotation() 144 { 145 return shumate_viewport_get_rotation(shumateViewport); 146 } 147 148 /** 149 * Get the current zoom level 150 * 151 * Returns: the current zoom level 152 */ 153 public double getZoomLevel() 154 { 155 return shumate_viewport_get_zoom_level(shumateViewport); 156 } 157 158 /** 159 * Gets the position on @widget that correspond to the given latitude and 160 * longitude. 161 * 162 * Params: 163 * widget = a #GtkWidget that uses @self as viewport 164 * latitude = the latitude 165 * longitude = the longitude 166 * x = return value for the x coordinate 167 * y = return value for the y coordinate 168 */ 169 public void locationToWidgetCoords(Widget widget, double latitude, double longitude, out double x, out double y) 170 { 171 shumate_viewport_location_to_widget_coords(shumateViewport, (widget is null) ? null : widget.getWidgetStruct(), latitude, longitude, &x, &y); 172 } 173 174 /** 175 * Set the maximal zoom level 176 * 177 * Params: 178 * maxZoomLevel = the maximal zoom level 179 */ 180 public void setMaxZoomLevel(uint maxZoomLevel) 181 { 182 shumate_viewport_set_max_zoom_level(shumateViewport, maxZoomLevel); 183 } 184 185 /** 186 * Set the minimal zoom level 187 * 188 * Params: 189 * minZoomLevel = the minimal zoom level 190 */ 191 public void setMinZoomLevel(uint minZoomLevel) 192 { 193 shumate_viewport_set_min_zoom_level(shumateViewport, minZoomLevel); 194 } 195 196 /** 197 * Set the reference map source 198 * 199 * Params: 200 * mapSource = a #ShumateMapSource or %NULL to set none. 201 */ 202 public void setReferenceMapSource(MapSource mapSource) 203 { 204 shumate_viewport_set_reference_map_source(shumateViewport, (mapSource is null) ? null : mapSource.getMapSourceStruct()); 205 } 206 207 /** 208 * Sets the rotation 209 * 210 * Params: 211 * rotation = the rotation 212 */ 213 public void setRotation(double rotation) 214 { 215 shumate_viewport_set_rotation(shumateViewport, rotation); 216 } 217 218 /** 219 * Set the zoom level 220 * 221 * Params: 222 * zoomLevel = the zoom level 223 */ 224 public void setZoomLevel(double zoomLevel) 225 { 226 shumate_viewport_set_zoom_level(shumateViewport, zoomLevel); 227 } 228 229 /** 230 * Gets the latitude and longitude corresponding to a position on @widget. 231 * 232 * Params: 233 * widget = a #GtkWidget that uses @self as viewport 234 * x = the x coordinate 235 * y = the y coordinate 236 * latitude = return location for the latitude 237 * longitude = return location for the longitude 238 */ 239 public void widgetCoordsToLocation(Widget widget, double x, double y, out double latitude, out double longitude) 240 { 241 shumate_viewport_widget_coords_to_location(shumateViewport, (widget is null) ? null : widget.getWidgetStruct(), x, y, &latitude, &longitude); 242 } 243 244 /** 245 * Increases the zoom level 246 */ 247 public void zoomIn() 248 { 249 shumate_viewport_zoom_in(shumateViewport); 250 } 251 252 /** 253 * Decreases the zoom level 254 */ 255 public void zoomOut() 256 { 257 shumate_viewport_zoom_out(shumateViewport); 258 } 259 }